<template>
  <div id="app">
    <!-- 渲染子路由 -->
    <router-view v-if="isRouteAlive"/>
  </div>
</template>


<script>
import {generaMenu} from "./util/menu";

export default {
  data() {
    return {
      isRouteAlive: true
    }
  },


  created() {
    // 刷新页面查询用户菜单
    let pathname = window.location.pathname;
    if (this.$store.state.accessToken != null) {
      if (pathname === '/login') {
        return
      }
      generaMenu();
    } else {
      if (pathname === '/login') {
        return
      }
    }
    // 上传访客信息
    // this.axios.post("/api/report");
  },

  provide() {
    return {
      reload: this.reload,
    }
  },

  methods: {
    //刷新页面
    reload() {
      this.isRouteAlive = false;
      this.$nextTick(function () {
        this.isRouteAlive = true;
      })
    }
  }

};
</script>
